/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.techshop.controller;
import com.techshop.model.Comment;
import com.techshop.service.CommentService;
import java.util.List;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.ViewScoped;

/**
 *
 * @author hai
 */
@ManagedBean(name="commentController")
@ViewScoped
public class CommentController extends AbstractController{
    Comment selectcomment = new Comment();
    List<Comment> listcomment;
    @ManagedProperty(value = "#{commentService}")
    CommentService commentService;
  /*@
   * Get Set Comment
    */
    public CommentService getCommentService() {
        return commentService;
    }
    public void setCommentService(CommentService commentService) {
        this.commentService = commentService;
    }

    
    
    public Comment getSelectcomment() {
        return selectcomment;
    }
    public void setSelectcomment(Comment selectcomment) {
        this.selectcomment = selectcomment;
    }

    public List<Comment> getListcomment() {
        return getCommentService().findAll();
    }
    public void setListcomment(List<Comment> listcomment) {
        this.listcomment = listcomment;
    }

   
    
     public void resetSelectComment(){
        selectcomment = new Comment();
    }
  public void btnDelete(){
        if(getCommentService().delete(getSelectcomment())){
            addInfoMessage("Xóa  thành công");
        }else{
            addErrorMessage("Xóa  không thành công");
        }
    }
  public void btnUpdate(){
        if(getCommentService().update(getSelectcomment())){
            addInfoMessage("Bình luận đã được duyệt");
        }else{
            addErrorMessage("Có lỗi!.");
        }
    }
   
    
}
